package com.cec.controller.admin;


import com.cec.dto.CategoryDTO;
import com.cec.service.admin.InfoService;
import com.cec.dto.InfoDTO;
import com.cec.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 资讯表 前端控制器
 * </p>
 *
 * @author lt
 * @since 2024-10-25
 */
@Slf4j
@RestController
@Api(tags = "资讯信息")
@RequestMapping("/admin/info")
public class InfoController {

    @Autowired
    private InfoService infoService;

    @GetMapping
    @ApiOperation("分页查询消息信息")
    public Result pageQueryInfo(InfoDTO infoDTO){
        log.info("InfoDTO-->{}",infoDTO);
        return infoService.pageQueryInfo(infoDTO);
    }

    @PostMapping()
    @ApiOperation("修改资讯信息")
    public  Result updateInfo(@RequestBody InfoDTO infoDTO){
        return infoService.updateInfo(infoDTO);
    }

    @PostMapping("/changeStatus")
    @ApiOperation("修改资讯状态")
    public Result updateInfoStatus(@RequestBody InfoDTO infoDTO){
        log.info("InfoDTO-->{}",infoDTO);
        return infoService.updateInfoStatus(infoDTO);
    }

    @GetMapping("/{id}")
    @ApiOperation("通过id查询资讯")
    public Result queryInfoById(@PathVariable Integer id){
        return infoService.queryInfoById(id);
    }

    @GetMapping("/jsonpInfo/{num}")
    @ApiOperation("添加资讯信息")
    public Result addInfo(@PathVariable Integer num){
        log.info("num-->{}",num);
        return infoService.addInfo(num);
    }

    @GetMapping("/type")
    @ApiOperation("资讯类型")
    public Result queryInfoType(CategoryDTO categoryDTO){
        return infoService.queryInfoType(categoryDTO);
    }

    @DeleteMapping("/logicDel/{id}")
    @ApiOperation("逻辑删除志愿者信息")
    public Result logicDeleteInfoById(@PathVariable Integer id){
        log.info("id-->{}",id);
        return infoService.logicDeleteInfoById(id);
    }

    @DeleteMapping("/logicBatchDel")
    @ApiOperation("逻辑批量删除志愿者信息")
    public Result logicBatchDeleteInfoByIds(@RequestBody List<Integer> ids){
        log.info("id-->{}",ids);
        return infoService.logicBatchDeleteInfoByIds(ids);
    }
}

